﻿Public Class Principal
    Private Sub Principal_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        Try
            LoginForm1.STATUSLabel1.Text = "DESLOGADO"
            LoginForm1.LOGINBindingSource1.EndEdit()
            LoginForm1.TableAdapterManager.UpdateAll(LoginForm1.LOGINDataSet)
        Catch ex As Exception
            MsgBox("ERRO AO DESLOGAR O USUÁRIO FAVOR ENTRAR EM CONTATO COM O ADMINISTRADOR" & ex.ToString)
            LoginForm1.Close()
        End Try
        LoginForm1.Close()
    End Sub
    Private Sub Principal_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'TODO: This line of code loads data into the 'CADASTRODataSet.CADASTRO' table. You can move, or remove it, as needed.
        Me.CADASTROTableAdapter.Fill(Me.CADASTRODataSet.CADASTRO)
        ToolStripStatusLabel2.Text = LoginForm1.USUARIOTextBox.Text
        Try
            ToolStripStatusLabel4.Text = "Versão " & My.Application.Deployment.CurrentVersion.ToString()
        Catch ex As Exception
            MsgBox("Sistema não instalado")
        End Try
        If LoginForm1.GRUPOComboBox.Text = "MASTER" Then
            USUÁRIOSToolStripMenuItem.Enabled = True
            BACKUPToolStripMenuItem.Enabled = True
        Else
            USUÁRIOSToolStripMenuItem.Enabled = False
            BACKUPToolStripMenuItem.Enabled = False
        End If
        If LoginForm1.USUARIOTextBox.Text = "CLAUDIA" Or LoginForm1.USUARIOTextBox.Text = "FABRICIO" Then
            BACKUPToolStripMenuItem.Enabled = True
        End If
    End Sub
    Private Sub SAIRToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SAIRToolStripMenuItem.Click
        If MsgBox("DESEJA REALMENTE SAIR", MsgBoxStyle.YesNo, "ATENÇÃO") = MsgBoxResult.Yes Then
            Me.Close()
        End If
    End Sub
    Private Sub USUÁRIOSToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles USUÁRIOSToolStripMenuItem.Click
        USUARIO.MdiParent = Me
        USUARIO.Show()
    End Sub
    Private Sub CADASTROToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CADASTROToolStripMenuItem.Click
        CADASTRO.MdiParent = Me
        CADASTRO.Show()
    End Sub
    Private Sub RELATORIOToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RELATORIOToolStripMenuItem.Click
        RELATORIO.MdiParent = Me
        RELATORIO.Show()
    End Sub

    Private Sub BACKUPToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BACKUPToolStripMenuItem.Click
        BACKUP.MdiParent = Me
        BACKUP.Show()
    End Sub

    Private Sub CADASTROBindingNavigatorSaveItem_Click(sender As System.Object, e As System.EventArgs)
        Me.Validate()
        Me.CADASTROBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.CADASTRODataSet)

    End Sub
End Class
